<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="text"/>

	<xsl:template match="formalAssertions">
		<xsl:text>Problems(</xsl:text>
		<xsl:for-each select="./formalRepresentation[not(position()=last())]">
			<xsl:apply-templates select="."/>,</xsl:for-each>
		<xsl:apply-templates select="./formalRepresentation[position()=last()]"/>
		<xsl:text>)</xsl:text>
	</xsl:template>

	<xsl:template match="formalRepresentation">
		<xsl:text>Theorem(</xsl:text>[<xsl:apply-templates select="assumption"/>],
			[<xsl:apply-templates select="objective/constraint"/>],
			[<xsl:apply-templates select="objective/*[1]"/>]
		<xsl:text>)</xsl:text>
	</xsl:template>

	<xsl:template match="conceptObject">
		<xsl:choose>
			<!--quantityFunction element could not end with ';'-->
			<xsl:when test="string(node-name(..))='argument' or string(node-name(..))='quantityFunction'">
				<xsl:apply-templates select="./*"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="./*"/>;</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="nondegeneracyCondition">
	</xsl:template>

	<xsl:template match="vocabulary">
		<xsl:value-of select="."/>
	</xsl:template>

	<xsl:template match="argument">(<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>,</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>)</xsl:template>

	<xsl:template match="pointer">
		<xsl:value-of select="."/>
		<xsl:if test="parent::declare and @type">
			<xsl:text>::</xsl:text>
			<xsl:value-of select="@type"/>;
			</xsl:if>
	</xsl:template>

	<xsl:template match="quantity">
		<xsl:value-of select="."/>
	</xsl:template>

	<xsl:template match="reference">
		<xsl:apply-templates select="./*[1]"/>:=<xsl:apply-templates select="./*[2]"/>
		<xsl:if test="not(conceptObject)">;</xsl:if>
	</xsl:template>

	<xsl:template match="quantityFunction">
		<xsl:if test="@name='times'">times(<xsl:for-each select="./*[not(position()=last())]">
				<xsl:apply-templates select="."/>,</xsl:for-each>
			<xsl:apply-templates select="./*[position()=last()]"/>)</xsl:if>
		<xsl:if test="@name='plus'">
			<xsl:for-each select="./*[not(position()=last())]">
				<xsl:apply-templates select="."/>+</xsl:for-each>
			<xsl:apply-templates select="./*[position()=last()]"/>
		</xsl:if>
		<xsl:if test="@name='minus'">
			<xsl:for-each select="./*[not(position()=last())]">
				<xsl:apply-templates select="."/>-</xsl:for-each>
			<xsl:apply-templates select="./*[position()=last()]"/>
		</xsl:if>
	</xsl:template>

	<xsl:template match="give">
		<!--skip -->
	</xsl:template>

</xsl:stylesheet>